<!-- <script src="../../router.js"></script> -->
<template>
  <div class="app-container app-container-compactness">

    <avue-data-tabs :option="avue_option" />

    <div style="margin-bottom: 15px;">
      <span style="margin-right: 10px;">订单类型：</span>
      <el-radio-group v-model="queryParams.orderType" size="mini" @change="handleQuery">
        <el-radio-button label="channel">渠道订单</el-radio-button>
        <el-radio-button label="bonded">保税仓订单</el-radio-button>
      </el-radio-group>
    </div>

    <el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px">
      <el-form-item style="margin-left:-18px;" label="订单号" prop="orderId">
        <el-input
          v-model="queryParams.orderId"
          style="width: 110px;"
          placeholder="请输入关键词"

          size="small"
        />
      </el-form-item>
      <el-form-item style="margin-left:-18px" label="订购人" prop="buyerName">
        <el-input
          v-model="queryParams.buyerName"
          style="width: 110px;"
          placeholder="请输入关键词"

          size="small"
        />
      </el-form-item>
      <el-form-item style="margin-left:-7px" label="订购人证件号码" prop="ConsigneeCode" label-width="110px">
        <el-input
          v-model="queryParams.ConsigneeCode"
          placeholder="请输入关键词"
          style="width: 120px; "
          size="small"
        />
      </el-form-item>
      <el-form-item label="订单时间" prop="orderDate">
        <el-date-picker
          v-model="queryParams.orderDate"
          style="     transform: translateY(5px);
    height: 20px;
    font-size: 12px;
     line-height: 20px;"
          size="small"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        />
      </el-form-item>
      <el-form-item label="订单状态" prop="push_order">
        <el-select v-model="queryParams.push_status" style="width: 150px" placeholder="订单状态" filterable allow-create clearable size="small">
          <el-option
            v-for="(dict,index) in orderStatusOptions"
            :key="index"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          style="border-radius: 0px;"
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
        >搜索</el-button>

        <el-button
          style="margin-left: 0px; border-radius: 0px;"
          icon="el-icon-refresh"
          size="mini"
          @click="resetQuery"
        >重置</el-button>
        <!--        <el-button-->
        <!--          style="margin-left: 0px; border-radius: 0px;"-->
        <!--          type="primary"-->
        <!--          plain-->
        <!--          icon="el-icon-download"-->
        <!--          size="mini"-->
        <!--          @click="openImport"-->
        <!--        >订单导入-->
        <!--        </el-button>-->
        <el-button
          style="margin-left: 0px; border-radius: 0px;"
          type="primary"
          plain
          size="mini"
          icon="el-icon-upload2"
          @click="openImport2"
        >订单导入
        </el-button>
        <el-button
          style="margin-left: 0px; border-radius: 0px;"
          type="primary"
          plain
          icon="el-icon-download"
          size="mini"
          @click="exportOrders"
        >订单导出
        </el-button>
      </el-form-item>

    </el-form>

    <!-- <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-upload2"
          size="mini"
          :disabled="multiple"
          @click="declare()"
        >批量申报</el-button>
        <el-button
          type="success"
          plain
          icon="el-icon-download"
          size="mini"
          :disabled="multiple"
          @click="select()"
        >批量同步</el-button>
        <el-button
          type="warning"
          plain
          icon="el-icon-male"
          size="mini"
          :disabled="multiple"
          @click="exportXml()"
        >导出XML报文</el-button>
      </el-col>
    </el-row> -->

    <el-table v-loading="loading" :data="list" style="width: 100%;" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center" />
      <!--      <el-table-column label="ID" align="center" prop="id" />-->
      <el-table-column label="来源订单号" align="center" prop="orderId" width="200" />
      <el-table-column label="订单日期" align="center" prop="orderDate" width="200" />
      <el-table-column label="订购/收货人" align="center" prop="buyerName" width="100">
        <template v-slot="scope">
          <span>{{ scope.row.buyerName || scope.row.contactName }}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column label="交易流水号" align="center" prop="payOrderNo" :show-overflow-tooltip="true" />-->
      <el-table-column label="订购人证件号" width="200" align="center" prop="ConsigneeCode" :show-overflow-tooltip="true" />
      <el-table-column label="订单金额" align="center" prop="amount" width="100" />
      <el-table-column label="订单支付类型" align="center" prop="HNACARD" width="150" :formatter="HNACARD_formatter" />
      <!-- <el-table-column label="海关订单状态" align="center" :formatter="statusFormat" /> -->
      <el-table-column label="订单状态" align="center" :formatter="xs_status" width="150" />
      <!--      <el-table-column label="订单类型" align="center" :formatter="statusVlive" />-->
      <!-- <el-table-column label="回执信息" align="center" prop="returnInfo" width="200" :show-overflow-tooltip="true" /> -->
      <el-table-column label="详情" align="center" width="100">
        <template v-slot="scope">
          <span v-if="scope.row.id > 116274 && scope.row._order_type != 10" style="color: #20a0ff;cursor:pointer;font-weight: bold;" @click="toDetails(scope.row)">查看</span>
          <span v-else style="color: #20a0ff;cursor:pointer" @click="see(scope.row)">查看</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width controls-class">
        <template v-slot="scope">

          <span v-if="scope.row.push_status == '未推送' && scope.row.tradeType == '0004' && '1' == scope.row.HNACARD && !scope.row.xs_payment">
            <el-button
              style="border-radius: 0px; width: 70px!important;height: 20px!important;"
              size="mini"
              type="danger"
              @click.prevent="open1(scope.row,'推单')"
            >预付卡推单</el-button>
          </span>

          <el-button
            v-if="1 == scope.row.is_need_push_payment_order && scope.row.xs_payment && 0 == scope.row.xs_payment.customsApply_status"
            style="border-radius: 0px; width: 70px!important;height: 20px!important;"
            size="mini"
            type="info"
            @click="Apply(scope.row,'推单')"
          >支付单推单</el-button>

          <span>
            <el-button
              v-if="pushOrderIsHide(scope.row)"
              style="border-radius: 0px; width: 70px!important;height: 20px!important;"
              size="mini"
              type="primary"
              @click.prevent="TuiSong(scope.row,'推单')"
            >推送订单</el-button>

            <el-button
              v-if="scope.row._order_type === 3"
              size="mini"
              type="warning"
              :disabled="scope.row.submitBtnStatus === false ? true : false"
              @click="OutKU(scope.row,'出库单下发')"
            >出库单下发</el-button>

            <el-button
              v-if="scope.row._order_type === 3 && scope.row.push_status !== '未推送'"
              size="mini"
              type="primary"
              @click="CNedit(scope.row,'修改')"
            >修改订单</el-button>
            <el-button
              v-if="scope.row._order_type === 2"
              size="mini"
              type="danger"
              @click="refund(scope.row,'退款')"
            >退款</el-button>
          </span>

          <!--  v-if="scope.row._order_type === 1" -->
          <!--          :disabled="scope.row.submitBtnStatus === false ? true : false"-->

          <!-- <el-button
            size="mini"
            type="primary"
            @click="declare(scope.row,'申报')"
          >申报/变更</el-button> -->
          <!-- <el-button
            size="mini"
            type="success"
            :disabled="scope.row.push_order === 0 ? true : false"
            @click="select(scope.row)"
          >同步回执</el-button> -->
          <span>
            <el-button
              style="border-radius: 0px; width: 70px!important;height: 20px!important;"
              size="mini"
              type="warning"
              @click="prints(scope.row)"
            >打印
            </el-button>
          </span>

          <el-dropdown trigger="click" @command="moreActionFunc($event,scope.row)">
            <el-button type="primary" size="mini">
              更多<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="updateOrderStatus">修改订单状态</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>

          <!--          <el-button type="primary" icon="el-icon-edit" circle @click="edit(scope.row)" />-->
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.limit" @pagination="getList" />
    <!-- 打印 -->
    <Print :open-one.sync="openOne" :order-id="orderId" />

    <!-- 修改 -->
    <el-dialog title="编辑" :visible.sync="open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" label-width="130px">
        <el-row>
          <el-col :span="8">
            <el-form-item prop="ebpCode">
              <span slot="label">
                <el-tooltip content="电商平台的海关注册登记编号或统一社会信用代码。" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                电商平台代码
              </span>
              <el-input v-model="form.ebpCode" placeholder="请输入电商平台代码" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="电商平台名称" prop="ebpName">
              <el-input v-model="form.ebpName" placeholder="请输入电商平台名称" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="paycomCode">
              <span slot="label">
                <el-tooltip content="支付企业的海关注册登记编号" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                支付企业代码
              </span>
              <el-input v-model="form.paycomCode" placeholder="请输入支付企业代码" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item prop="paycomName">
              <span slot="label">
                <el-tooltip content="支付企业在海关注册登记的企业名称" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                支付企业名称
              </span>
              <el-input v-model="form.paycomName" placeholder="请输入支付企业名称" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="amount">
              <span slot="label">
                <el-tooltip content="商品实际成交价 FOB(不含运杂费)，含非现金抵扣金额" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                商品金额
              </span>
              <el-input v-model="form.amount" placeholder="请输入商品金额" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="distributionfee">
              <span slot="label">
                <el-tooltip content="无则填写"0"" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                运杂费
              </span>
              <el-input v-model="form.distributionfee" placeholder="请输入运杂费" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item prop="discount">
              <span slot="label">
                <el-tooltip content="非现金抵扣金额（使用积分、虚拟货币、代金券等非现金支付金额，无则填写 “0”" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                代扣税款
              </span>
              <el-input v-model="form.discount" placeholder="请输入代扣税款" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="tax">
              <span slot="label">
                <el-tooltip content="企业预先代扣的税款金额，无则填写"0"" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                代扣税款
              </span>
              <el-input v-model="form.tax" placeholder="请输入代扣税款" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="realPayment">
              <span slot="label">
                <el-tooltip content="商品价格+运杂费+代扣税款-非现金抵扣金额，与支付凭证 的支付金额一致" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                实际支付金额
              </span>
              <el-input v-model="form.realPayment" placeholder="请输入实际支付金额" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item prop="contactMobile">
              <span slot="label">
                <el-tooltip content="订购人的交易平台注册号" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                订购人注册号
              </span>
              <el-input v-model="form.contactMobile" placeholder="请输入订购人注册号" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="buyerName">
              <span slot="label">
                <el-tooltip content="订购人的真实姓名" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                订购人姓名
              </span>
              <el-input v-model="form.buyerName" placeholder="请输入订购人姓名" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="ConsigneeCode">
              <span slot="label">
                <el-tooltip content="订购人的身份证件号码" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                订购人证件号码
              </span>
              <el-input v-model="form.ConsigneeCode" placeholder="请输入订购人证件号码" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="订购人电话" prop="contactMobile">
              <el-input v-model="form.contactMobile" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="payOrderNo">
              <span slot="label">
                <el-tooltip content="支付企业唯一的支付流水号" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                支付交易编号
              </span>
              <el-input v-model="form.payOrderNo" placeholder="请输入支付交易编号" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收货人姓名" prop="contactName">
              <el-input v-model="form.contactName" placeholder="请输入收货人姓名" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item prop="contactMobile">
              <span slot="label">
                <el-tooltip content="收货人联系电话，必须与电子运单的收货人电话一致" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                收货人电话
              </span>
              <el-input v-model="form.contactMobile" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="contactAddr">
              <span slot="label">
                <el-tooltip content="必须与电子运单的收货省市区一致" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                收货省市区
              </span>
              <el-input v-model="form.contactAddr" placeholder="请输入收货省市区" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="detailAddr">
              <span slot="label">
                <el-tooltip content="必须与电子运单的收货收货详细地址一致" placement="top">
                  <i class="el-icon-info" />
                </el-tooltip>
                收货详细地址
              </span>
              <el-input v-model="form.detailAddr" placeholder="请输入收货详细地址" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <!--        <el-row>-->
        <!--          <el-col :span="24">-->
        <!--            <el-form-item label="备注">-->
        <!--              <el-input v-model="form.note" type="textarea" />-->
        <!--            </el-form-item>-->
        <!--          </el-col>-->
        <!--        </el-row>-->

        <el-table :data="form.goodsListStr" border stripe style="width: 100%;">
          <el-table-column prop="productName" label="企业商品名称">
            <template slot-scope="scope">
              <el-input v-model="scope.row.productName" :value="scope.row.productName" placeholder="企业商品名称" />
            </template>
          </el-table-column>
          <el-table-column prop="barcode" label="企业商品货号">
            <template slot-scope="scope">
              <el-input v-model="scope.row.barcode" :value="scope.row.barcode" placeholder="企业商品货号" />
            </template>
          </el-table-column>
          <el-table-column prop="productName" label="规格型号">
            <template slot-scope="scope">
              <el-input v-model="scope.row.GModel" :value="scope.row.GModel" placeholder="规格型号" />
            </template>
          </el-table-column>
          <el-table-column prop="barcode" label="条形码">
            <template slot-scope="scope">
              <el-input v-model="scope.row.barcode" :value="scope.row.barcode" placeholder="条形码" />
            </template>
          </el-table-column>
          <el-table-column prop="Unit" label="计量单位">
            <template slot-scope="scope">
              <el-input v-model="scope.row.Unit" :value="scope.row.Unit" placeholder="计量单位" />
            </template>
          </el-table-column>
          <el-table-column prop="Unit" label="原产国">
            <template slot-scope="scope">
              <el-input v-model="scope.row.business_addr" :value="scope.row.business_addr" placeholder="原产国" />
            </template>
          </el-table-column>
          <el-table-column prop="num" label="数量">
            <template slot-scope="scope">
              <el-input v-model="scope.row.num" :value="scope.row.num" placeholder="数量" />
            </template>
          </el-table-column>
          <el-table-column prop="price" label="单价">
            <template slot-scope="scope">
              <el-input v-model="scope.row.price" :value="scope.row.price" placeholder="单价" />
            </template>
          </el-table-column>
          <el-table-column prop="weight" label="净重">
            <template slot-scope="scope">
              <el-input v-model="scope.row.weight" :value="scope.row.weight" placeholder="净重" />
            </template>
          </el-table-column>
        </el-table>
        <el-row style="top: 30px;text-align:center;">
          <el-col :span="24">
            <el-form-item size="large">
              <el-button type="primary" @click="onSubmit">提交</el-button>
              <el-button @click="open === false">取消</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
    <!-- 回执信息-->
    <el-dialog title="回执信息" :visible.sync="dialogVisible" width="30%">
      <span>{{ info }}</span>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false">关 闭</el-button>
      </span>
    </el-dialog>
    <!-- 查看详情 -->
    <ComOrderDetails :show.sync="show" :form="form" :type="type" />
    <Detail :show.sync="dshow" :form="dform" :title="title" />
    <refund :show.sync="rshow" :form="rform" :title="rtitle" />
    <CnEdit :show.sync="cshow" :form="cform" :title="ctitle" />
    <!-- 账册导入 -->
    <Import :export_open.sync="export_open" />

    <OrderImport v-if="importOpen" :import-open.sync="importOpen" />

    <UpdateOrderStatus :form="updateOrderStatusForm" :update-order-status-dialog.sync="updateOrderStatusDialog" />

    <Credit :credit-dialog-visible.sync="creditDialog" />
  </div>
</template>

<script>
import { list, orderPush, orderSelect, exportOrderXml } from '@/api/order'
import {
  getTenantOrdersList,
  orderInfo,
  apiOrderDetail,
  orderApplyPush,
  orderXsRefund,
  createOrder,
  apiSaleOrder,
  apiPrepay,
  exportOrders
} from '@/api/externalGoods'
import Print from './Print'
import Detail from './Detail'
import refund from './refund'
import CnEdit from './CnEdit'
import Import from './Imports'
import UpdateOrderStatus from './UpdateOrderStatus'
import OrderImport from '@/views/externalGoods/tenantOrders/OrderImport'
import { exportStock } from '@/api/stock'
import Credit from '@/views/externalGoods/tenantOrders/Credit'
export default {
  name: 'Index',
  components: {
    Credit,
    OrderImport,
    Print,
    Detail,
    refund,
    CnEdit,
    Import,
    UpdateOrderStatus
  },
  data() {
    return {
      avue_option: {
        span: 12,
        decimals: 2,
        data: [
          {
            click: function(item) {
              // alert(JSON.stringify(item))
            },
            title: '预授信额度',
            subtitle: '实时',
            count: this.$store.state.user.userInfo.credit_amount,
            // allcount: 10222,
            // text: '当前分类总记录数',
            color: 'rgb(27, 201, 142)',
            key: '信'
          },
          {
            click: (item) => {
              this.creditDialog = true
            },
            title: '可用金额',
            subtitle: '实时',
            count: this.$store.state.user.userInfo.credit_available_amount,
            // allcount: 10222,
            text: '> 消费记录 <',
            color: 'rgb(178, 159, 255)',
            key: '可'
          }
        ]
      },
      updateOrderStatusDialog: false,
      creditDialog: false,
      updateOrderStatusForm: {},
      importOpen: false,
      // 打印
      openOne: false,
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 非多个禁用
      multiple: true,
      // 是否显示弹出层
      open: false,
      dialogVisible: false,
      export_open: false,
      // 表单参数
      form: {},
      info: '',
      // 表单校验
      rules: {
        name: [
          { required: true, message: '名称不能为空', trigger: 'blur' }
        ]
      },
      // 订单状态
      HNACARDOptions: [
        { value: 0, label: '支付订单' },
        { value: 1, label: '预付卡订单' }
      ],
      PushOrderOptions: [
        { 'value': 0, 'label': '未推送' },
        { 'value': 1, 'label': '已推送' },
        { 'value': 2, 'label': '电子口岸申报中' },
        { 'value': 3, 'label': '发送海关成功' },
        { 'value': 4, 'label': '发送海关失败' },
        { 'value': 100, 'label': '海关退单' },
        { 'value': 120, 'label': '海关入库' }
      ],
      VliveOrderOptions: [
        { 'value': 0, 'label': '海关订单' },
        { 'value': 1, 'label': '候鸟订单' },
        { 'value': 2, 'label': '新生订单' },
        { 'value': 3, 'label': '菜鸟订单' }
      ],
      XsOrderOptions: [
        { 'value': 0, 'label': '未付款' },
        { 'value': 1, 'label': '已付款' }
      ],
      orderStatusOptions: [
        { 'value': -2, 'label': '待付款' },
        { 'value': -1, 'label': '已取消' },
        { 'value': 0, 'label': '待发货' },
        { 'value': 1, 'label': '已发货' },
        { 'value': 2, 'label': '已收货' },
        { 'value': 3, 'label': '海关审核中 | 仓库分拣打包' },
        { 'value': 3, 'label': '海关审核中 | 仓库分拣打包' },
        { 'value': 501, 'label': '退货退款' },
        { 'value': 502, 'label': '未推送' },
        { 'value': 6001, 'label': '订单处理中' }
      ],
      // 查询参数
      queryParams: {
        page: 1,
        limit: 20,
        orderId: undefined,
        ConsigneeCode: undefined,
        contactName: undefined,
        // 日期范围
        orderDate: [],
        pushOrder: undefined,
        orderType: 'channel' // 保持默认值
      },
      show: false,
      ids: [],
      orderId: '',
      dshow: false,
      dform: {},
      title: '',
      rshow: false,
      rform: {},
      rtitle: '',
      type: '',
      cshow: false,
      cform: {},
      ctitle: ''
    }
  },
  created() {
    this.getList()
  },
  methods: {
    creditFunc() {
      console.log(this)
    },
    updateOrderStatusShowDialog(row) {
      this.updateOrderStatusDialog = true
      const data = {
        push_status: row.push_status,
        orderId: row.orderId,
        id: row.id
      }
      this.updateOrderStatusForm = data
    },
    moreActionFunc(val, row) {
      console.log('laile', val)
      if (val == 'updateOrderStatus') { // 修改订单
        // this.updateOrderStatus(row)

        this.$prompt('请输入密码', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputValidator: (value) => {
            if (value !== '666666') {
              return false
            }
          },
          // inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
          inputErrorMessage: '密码错误'
        }).then(({ value }) => {
          this.updateOrderStatusShowDialog(row)
        })
      }
    },

    exportOrders() {
      const that = this
      that.loading = true
      let params = {}
      // exportType 1:选中导出 2：列表导出
      if (that.ids.length > 0) {
        params.ids = that.ids.toString()
      } else {
        params = that.queryParams
      }

      exportOrders(params).then(response => {
        // console.log(response)
        if (response.code === 10000) {
          var url = response.data.url.replace('127.0.0.1:8080', 'cross.qekj.net')
          window.open(url)
        } else {
          that.$message.error(response.message)
        }
        that.loading = false
      })
    },
    // 推送订单按钮是否可以点击
    pushOrderIsHide(row) {
      // return true
      if (row.push_status === '已取消') return false
      if (row.push_status === '订单处理中') return false
      // 有订单号、推过了
      if (row.order_nos.length) return false

      if (row.is_need_push_payment_order == 1) { // 需要 跨境
        if (row.pay_type == 3) {
          if (!row.xs_payment) return false // 是否支付过

          // 判断是否推送过支付单
          if (row.xs_payment.customsApply_status == 0) return false
        }
      }

      // 保税仓订单
      if (row._order_type == 11) return false

      return true
    },
    HNACARD_formatter(row, column) {
      let pay_type = row.HNACARD
      for (const d of this.HNACARDOptions) {
        if (pay_type == d.value) {
          pay_type = d.label
          break
        }
      }
      return pay_type
    },
    CNedit(row, type) {
      this.cshow = true
      this.cform = row
      this.ctitle = type
    },
    // 预付卡推单
    open1(row) {
      this.$confirm('此操作将使用预付卡支付订单，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        console.log(row, 'row')
        apiPrepay(row.id).then((res) => {
          if (res.code === 10000) {
            this.$message({
              type: 'success',
              message: '推送成功!'
            })
            this.getList()
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        })
      })
    },
    OutKU(row, type) {
      apiSaleOrder(row.id).then(response => {
        console.log(response)
        if (response.code === 10000) {
          this.$message({
            message: '下发成功',
            type: 'success'
          })
          this.getList()
        } else {
          this.$message({
            message: response.message,
            type: 'error'
          })
        }
      })
    },
    TuiSong(row, type) {
      createOrder(row.id).then(response => {
        console.log(response)
        if (response.code === 10000) {
          this.$message({
            message: '推送成功',
            type: 'success'
          })
          this.getList()
        } else {
          this.$message({
            message: response.message,
            type: 'error'
          })
        }
      })
    },
    toDetails(row) {
      this.$router.push({
        path: '/externalGoods/tenantOrdersDetails',
        query: { id: row.orderId }
      })
    },
    /** 查询订单详情 */
    see(row) {
      orderInfo({ orderId: row.orderId, type: 1 }).then(response => {
        if (response.code === 10000) {
          this.form = response.data
          if (this.form._order_type === 1 || this.form._order_type === 3 || this.form._order_type == 10) {
            this.type = 'sss'
          } else {
            this.type = undefined
          }
          // if (row._order_type == 1) {
          //   apiOrderDetail(row.id).then(response => {
          //     if (response.code === 10000) {
          //       this.form.apiOrderDetail = response.data
          //     }
          //   })
          // }
          this.show = true
        }
      })
    },
    /** 查询订单列表 */
    getList() {
      this.loading = true
      // console.log(this.queryParams)
      getTenantOrdersList(this.queryParams).then(response => {
        // console.log(response)
        if (response.code === 10000) {
          this.list = response.data
          this.total = response.count
          this.list.forEach(item => {
            if (item._order_type == 0) {
              item.order_status = '海关订单'
            } else if (item._order_type == 1) {
              item.order_status = '候鸟订单'
            } else if (item._order_type == 2) {
              item.order_status = '新生订单'
            } else {
              item.order_status = '菜鸟订单'
            }
          })
          this.loading = false
        }
      })
    },
    /** 状态字典翻译 */
    statusFormat(row, column) {
      let status = row.push_order
      for (const d of this.PushOrderOptions) {
        if (row.push_order === d.value) {
          status = d.label
          break
        }
      }
      return status
    },
    statusVlive(row, column) {
      let status = row._order_type
      for (const d of this.VliveOrderOptions) {
        if (row._order_type === d.value) {
          status = d.label
          break
        }
      }
      return status
    },
    xs_status(row, column) {
      let status = row._order_type
      if (row.order_status == '候鸟订单' || row.order_status == '菜鸟订单') {
        return row.push_status
      }
      for (const d of this.XsOrderOptions) {
        if (row.xs_status == d.value) {
          status = d.label
          break
        }
      }
      return status
    },
    refund(row, type = '退款') {
      this.rshow = true
      this.rform = row
      this.rtitle = type
      return
      const that = this
      const postIds = row ? row.id : this.ids.toString()
      that.$confirm('是否' + type + postIds + '等订单信息?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        orderXsRefund(postIds).then(response => {
          console.log(response)
          if (response.code === 10000) {
            that.$message.success(response.message)
          } else {
            that.$message.error(response.message)
          }
          that.getList()
        })
      }).catch(() => {})
    },
    Apply(row, type = '推单') {
      this.dshow = true
      this.dform = row
      this.title = type
    },
    /** (申报/变更/重新)订单 */
    declare(row, type = '申报') {
      const that = this
      const postIds = row ? row.orderId : this.ids.toString()
      that.$confirm('是否' + type + postIds + '等订单信息?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        orderPush({ orderId: postIds }).then(response => {
          if (response.code === 10000) {
            that.$message.success(response.message)
          }
          that.getList()
        })
      }).catch(() => {})
    },
    /** 导出xml文件 */
    exportXml() {
      if (this.ids.length === 0) {
        this.$message.error('请勾选订单')
        return
      }
      exportOrderXml({ orderId: this.ids }).then(response => {
        if (response.code === 10000) {
          const url = window.URL.createObjectURL(
            new Blob([response.data], { type: 'text/xml' })
          )
          const link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', 'CEB311Message.xml')
          document.body.appendChild(link)
          link.click()
        }
      })
    },
    /** 修改订单弹窗 */
    edit(row) {
      orderInfo({ orderId: row.orderId, type: 1 }).then(response => {
        if (response.code === 10000) {
          this.form = response.data
          this.open = true
        }
      })
    },
    /** 修改提交 */
    onSubmit() {
      orderInfo({ form: this.form, type: 2 }).then(response => {
        if (response.code === 10000) {
          this.$message.success(response.message)
          this.open = false
          this.getList()
        } else {
          this.$message.error(response.message)
        }
      })
    },
    /** 查询回执 */
    select(row) {
      const that = this
      const postIds = row ? row.orderId : this.ids.toString()
      that.$confirm('是否同步' + postIds + '等订单回执?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        orderSelect({ orderId: postIds }).then(response => {
          if (response.code === 10000) {
            if (row) {
              that.dialogVisible = true
              that.info = response.data
            } else {
              that.$message.success(response.message)
            }
            that.getList()
          } else {
            that.$message.error(response.message)
          }
        })
      }).catch(() => {})
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        page: 1,
        limit: 10,
        orderId: undefined,
        ConsigneeCode: undefined,
        contactName: undefined,
        startTime: undefined,
        endTime: undefined,
        orderDate: [],
        orderType: 'channel' // 保持默认值
      }
      this.handleQuery()
    },

    // 打开导入弹窗
    openImport() {
      this.export_open = true
      console.log(this.export_open, '111')
    },
    openImport2() {
      this.importOpen = true
    },
    /** 提交时间改变 */
    datePick(value) {
      if (value) {
        this.queryParams.startTime = value[0]
        this.queryParams.endTime = value[1]
      }
    },
    /** 选中的项 */
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orderId)
      this.multiple = !selection.length
    },
    /** 打印 */
    prints(row) {
      this.orderId = row.orderId
      console.log(this.orderId)
      this.openOne = true
    }

  }
}
</script>
<style lang="less" >

.avue-data-tabs {
  .item {
    height: 120px;
  }
  .item-footer>p{
    color:orangered;
    font-weight: bold;
  }
}

  .el-button {
    /* overflow: hidden;
    text-overflow: ellipsis;
    white-space:nowrap; */
  }
/* >>>.el-button span {*/
/*  position: relative;*/
/*  bottom:2px;*/
/*  overflow: hidden;*/
/*  text-overflow: ellipsis;*/
/*  white-space:nowrap;*/
/*}*/
/* >>> th.controls-class .cell{*/
/*   height: 23px !important;*/
/*   line-height: 23px !important;*/
/* }*/

</style>
